/*
 * @Author: Lw
 * @Date: 2022-09-01 16:21:58
 * @LastEditors: Lw
 * @LastEditTime: 2022-09-28 17:49:17
 */
const hash = {
  name: '名称',
  code: '编码',
  time: '时间',
  address: '地址',
}
const columns = Object.keys(hash).map((key) => {
  const label = hash[key]
  return {
    title: label,
    key: key,
    width: 'auto',
    resizable: true,
    ellipsis: {
      tooltip: true,
    },
  }
})
const btns = [
  { label: '新增', value: 'add', type: 'info', position: 'left' },
  { label: '批量删除', value: 'delBatch', type: 'error', position: 'left' },
  { label: '导出', value: 'export', type: 'info', position: 'right' },
  { label: '自定义', value: 'custom', type: 'info', position: 'row-right', disabled: true },
  {
    label: '详情',
    value: 'info',
    type: 'info',
    position: 'row-right',
    disabled: (row) => row.code == 0,
  },
  { label: '编辑', value: 'edit', type: 'info', position: 'row-right' },
  { label: '删除', value: 'del', type: 'error', position: 'row-right' },
  { label: '更多选项1', value: 'more1', position: 'row-right-more' },
  { label: '更多选项2', value: 'more2', position: 'row-right-more' },
  { label: '更多选项3', value: 'more3', position: 'row-right-more', disabled: true },
]
const searchOptions = [
  {
    label: '名称',
    key: 'name',
    type: 'text',
    span: 1,
  },
  {
    label: '编码',
    key: 'code',
    type: 'text',
    span: 1,
  },
  {
    label: '类型',
    key: 'type',
    type: 'select',
    options: [
      { label: '类型1', value: 1 },
      { label: '类型2', value: 2 },
      { label: '类型3', value: 3 },
      { label: '类型4', value: 4 },
    ],
    span: 1,
  },
]

const formOptions = [
  {
    label: '名称',
    key: 'name',
    type: 'text',
    maxlength: 10,
    span: 1,
  },
  {
    label: '编码',
    key: 'code',
    type: 'text',
    span: 1,
  },
  {
    label: '类型',
    key: 'type',
    type: 'select',
    options: [
      { label: '类型1', value: 1 },
      { label: '类型2', value: 2 },
      { label: '类型3', value: 3 },
      { label: '类型4', value: 4 },
    ],
    span: 1,
  },
  {
    label: '地址',
    key: 'address',
    type: 'text',
    span: 2,
  },
  {
    label: '自定义',
    key: 'custom',
    type: 'slot',
    span: 2,
  },
]
const rules = {
  name: {
    required: true,
    message: '必填',
  },
  code: {
    required: true,
    message: '必填',
  },
  type: {
    required: true,
    message: '必填',
  },
}
export default {
  // 表格列头配置
  columns,
  // 当前页码，不传参就是不使用分页功能
  page: 1,
  // 每页条数
  pageSize: 10,
  // 数据总量
  total: 0,
  // 按钮配置
  btns,
  // 是否开启多选功能
  selection: true,
  selectionDisabled: (row) => {
    return row.code < 4
  },
  // 树形数据是否级联
  // cascade: true,
  // 表格高度，不填就是自动
  // height: 800,
  // 表格固定宽度，不填就是自动
  // scrollX: 1400,
  // 操作栏宽度，不填就是150，只够容纳详情、编辑、删除
  operateWidth: 240,
  // 查询栏配置
  searchOptions,
  // 表单配置
  formOptions,
  // 表单验证
  rules,
}
